using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class OE_ORDERMap : EntityTypeConfiguration<OE_ORDER>
    {
        public OE_ORDERMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.OrderPhysician)
                .HasMaxLength(6);

            this.Property(t => t.AdmissionID)
                .HasMaxLength(10);

            this.Property(t => t.Status)
                .IsFixedLength()
                .HasMaxLength(1);

            this.Property(t => t.Item)
                .HasMaxLength(10);

            this.Property(t => t.Location)
                .HasMaxLength(3);

            this.Property(t => t.CollectionTime)
                .HasMaxLength(10);

            this.Property(t => t.CancelReason)
                .HasMaxLength(100);

            this.Property(t => t.Location2)
                .HasMaxLength(3);

            // Table & Column Mappings
            this.ToTable("OE_ORDER");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.OrderPhysician).HasColumnName("OrderPhysician");
            this.Property(t => t.OrderNote).HasColumnName("OrderNote");
            this.Property(t => t.AdmissionID).HasColumnName("AdmissionID");
            this.Property(t => t.PatientIID).HasColumnName("PatientIID");
            this.Property(t => t.StartingDate).HasColumnName("StartingDate");
            this.Property(t => t.EndingDate).HasColumnName("EndingDate");
            this.Property(t => t.Priority).HasColumnName("Priority");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.Item).HasColumnName("Item");
            this.Property(t => t.OrderUser).HasColumnName("OrderUser");
            this.Property(t => t.ProcessUser).HasColumnName("ProcessUser");
            this.Property(t => t.OrderDate).HasColumnName("OrderDate");
            this.Property(t => t.ProcessDate).HasColumnName("ProcessDate");
            this.Property(t => t.Qty).HasColumnName("Qty");
            this.Property(t => t.Return_Qty).HasColumnName("Return_Qty");
            this.Property(t => t.Location).HasColumnName("Location");
            this.Property(t => t.ExpiryDate).HasColumnName("ExpiryDate");
            this.Property(t => t.ProcessNote).HasColumnName("ProcessNote");
            this.Property(t => t.Department).HasColumnName("Department");
            this.Property(t => t.DX).HasColumnName("DX");
            this.Property(t => t.CollectionTime).HasColumnName("CollectionTime");
            this.Property(t => t.Request).HasColumnName("Request");
            this.Property(t => t.Print).HasColumnName("Print");
            this.Property(t => t.BeepCount).HasColumnName("BeepCount");
            this.Property(t => t.ReadyBeepCount).HasColumnName("ReadyBeepCount");
            this.Property(t => t.ReturnConfirmed).HasColumnName("ReturnConfirmed");
            this.Property(t => t.CancelReason).HasColumnName("CancelReason");
            this.Property(t => t.ORd_ProcessQty).HasColumnName("ORd_ProcessQty");
            this.Property(t => t.Location2).HasColumnName("Location2");
            this.Property(t => t.ExpiryDate2).HasColumnName("ExpiryDate2");
            this.Property(t => t.ORd_ProcessQty2).HasColumnName("ORd_ProcessQty2");
            this.Property(t => t.Return_Qty2).HasColumnName("Return_Qty2");

            // Relationships
            this.HasOptional(t => t.admision)
                .WithMany(t => t.OE_ORDER)
                .HasForeignKey(d => d.AdmissionID);
            this.HasOptional(t => t.Item1)
                .WithMany(t => t.OE_ORDER)
                .HasForeignKey(d => d.Item);
            this.HasOptional(t => t.Name)
                .WithMany(t => t.OE_ORDER)
                .HasForeignKey(d => d.OrderUser);
            this.HasOptional(t => t.Name1)
                .WithMany(t => t.OE_ORDER1)
                .HasForeignKey(d => d.ProcessUser);
            this.HasOptional(t => t.Oe_Priority)
                .WithMany(t => t.OE_ORDER)
                .HasForeignKey(d => d.Priority);
            this.HasOptional(t => t.request1)
                .WithMany(t => t.OE_ORDER)
                .HasForeignKey(d => d.Request);
            this.HasOptional(t => t.Vend)
                .WithMany(t => t.OE_ORDER)
                .HasForeignKey(d => d.OrderPhysician);

        }
    }
}
